<?php

/**
*Form Builder & Admin Generator

*@author marcio <opi14@op.pl>, <polishvodka7@gmail.com>
*@copyright Copyright (c) 2011, marcio
*@version 1.6.5
*/

//wyjatek rzycany przez form builider'a

class Volta_Form_Builider_Exception extends Exception
{

	/**
	Zwraca pelny komunikat bledu
	*@access public
	@return string $exception zwraca blad
	*/
	public function get()
	{
		$exception = "[error] " . $this -> getMessage()."<Br />";
		$exception .= "[{$this -> getCode()}]code error ";
		$exception .= "File: " . $this -> getFile()."<Br />";
		$exception .= "At line " . $this -> getLine()."<Br />";
		$exception .= "Backtrace: " . $this -> getTraceAsString();
		return $exception;
	}

	/**
	Zwraca tylko tresc bledu
	*@access public
	@return string $this -> getMessage() zwraca blad
	*/
	public function __toString() 
	{
		return $this -> getMessage();
	}

}

//wyjatki rzucane przez admin generator

class Volta_Admin_Generator_Exception extends Exception
{
	public function __toString() 
	{
		return $this -> getMessage();
	}
}

class Volta_Admin_Generator_NoRows_Exception extends Exception { }

class Volta_Admin_Generator_NoAction_Exception extends Exception { }

class Volta_Admin_Generator_Csrf_Exception extends Exception { }

//wyjatki acl'a

class Volta_Acl_Exception extends Exception { }

class Volta_Acl_Deny_Exception extends Exception { }

//wyjatek uwierzytelnienia

class Volta_Auth_Exception extends Exception { }

//wyjatek elementow formularza

class Volta_Form_Element_Exception extends Exception { }

//wyjatki dla mysql

class Volta_Mysql_Adapter_Exception extends Exception { }

class Volta_Mysql_Adapter_Connection_Exception extends Exception { }

class Volta_Mysql_Adapter_DbSelect_Exception extends Exception { }

class Volta_Mysql_Adapter_Query_Exception extends Exception 
{
	public function __construct($message = null, $code = 0, $sql, $profiler, $debug)
	{
		if($debug === 'dev')
		{
			$err = '<table align="center">
					<tr><td><p>Ilosc zapytan: '.$profiler['all_queries'].' Laczny czas: '.$profiler['all_time'].'</p></td></tr>
					</table>
					<table align="center">
					<tr><td>Sql</td><td>Czas</td></tr>';
					
					unset($profiler['all_queries'], $profiler['all_time']);
					foreach($profiler as $qid => $data)
						$err .= '<tr><td>'.$data['query'].'</td><td>'.$data['time'].'</td></tr>';
					
			$err .= '</table>
					<div align="center" style="padding:5px;margin:5px;background-color:#C0C0C0;border:1px solid #ff0033;"><b>'.$message.'</b></div>';
		}
		
		else
			$err = 'Wystapil blad podczas zapytania do bazy.';
		
		parent::__construct($err, $code);
	}
}


?>